#ifdef _CH_
#pragma package <opencv>

#endif

#ifndef _EiC
#include "cv.h"
#include "highgui.h"
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
#endif

#define NUMBER 100
#define DELAY 5


int main( int argc, char** argv )
{
  //Inicializace wokna
  cvNamedWindow("win1", CV_WINDOW_AUTOSIZE); 
  cvMoveWindow("win1", 100, 100); // offset from the UL corner of the screen
  
  cvNamedWindow("wcaptured", CV_WINDOW_AUTOSIZE); 
  cvMoveWindow("wcaptured", 600, 600); // offset from the UL corner of the screen
  
  //Inicialiozace obrazkovych cache
  IplImage* img=0;
  IplImage* img2=0; 
  //nahrani obrazku
  string fileName = "C:\pozadi.bmp"; 
  img=cvLoadImage("C:\pozadi.bmp",0);
  if(!img) printf("Could not load image file: %s\n",fileName);


 //Kamera
 CvCapture* capture = cvCaptureFromCAM(0); // capture from video device #0
for (int n=10; n>0; n++) {


 //Ovladani smicky pomoci klaves
int c = cvWaitKey();
if( c == 'w') {break;}
char key = (char) c;
cout << "\n Stisknuta klavesa:" << key;
 if ((c == 'c') || (c == ' ') )
 {
   if(!cvGrabFrame(capture)){              // capture a frame 
     printf("Could not grab a frame\n\7");
     exit(0);
   }
img=cvRetrieveFrame(capture);           // retrieve the captured frame


  //zobrazeni 
  cvShowImage("win1",img);
  //Ulozeni obrazku pro spracovani
  if ( ( c == ' '))
     {
     img2=cvCloneImage(img); 
     cvShowImage("wcaptured",img2);
     
     }     

 }
 


//Zacatek Square algorithmu






//Konec Square algoritmu












}
cvReleaseCapture(&capture);
    return 0;
}

#ifdef _EiC
main(1,"pokus.c");
#endif
